package com.atguigu.gmall.utils;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;


public class KeywordUtil {
    public static List<String> analyze(String text) {

        ArrayList<String> result = new ArrayList<>();
        StringReader stringReader = new StringReader(text);
        IKSegmenter ikSegmenter = new IKSegmenter(stringReader, true);
        Lexeme next = null;
        try {
            while ((next = ikSegmenter.next()) != null) {
                String word = next.getLexemeText();
                result.add(word);
            }
        }catch (IOException e){
            e.printStackTrace();
        }

        return result;
    }

    public static void main(String[] args) throws IOException {
        System.out.println(analyze("尚硅谷大数据部门"));
    }

}
